{% extends "base.html" %}
<!-- issue.html -->
{% load node_tags %}
{% load extra_tags %}
{% load extra_filters %}
{% load general_sidebar_tags %}
{% load smart_if %}
{% load humanize %}
{% load i18n %}
{% load cache %}
{% block metadescription %}{{ issue.meta_description }}{% endblock %}
{% block metakeywords %}{{issue.tagname_meta_generator}}{% endblock %}
{% block meta %}
        <link rel="canonical" href="{{settings.APP_BASE_URL}}{{issue.get_absolute_url}}" />
        <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ issue.get_absolute_url }}?type=rss">
{% endblock %}
{% block title %}{% spaceless %}{{ issue.headline }}{% endspaceless %}{% endblock %}
{% block forejs %}
        {% if not issue.nis.closed %}
        <script type='text/javascript' src='{% media  "/media/js/debate.js" %}'></script>
        <script type='text/javascript' src='{% media  "/media/js/jquery.caret.js" %}'></script>
        <script type='text/javascript' src='{% media  "/media/js/wmd/showdown.js" %}'></script>
        <script type='text/javascript' src='{% media  "/media/js/wmd/wmd.js" %}'></script>

        <link rel="stylesheet" type="text/css" href="{% media  "/media/style/issue.css" %}" />
        <link rel="stylesheet" type="text/css" href="{% media  "/media/js/wmd/wmd.css" %}" />

        {% if embed_youtube_videos %}
        <script type='text/javascript' src='{% media  "/media/js/viewbox_min.js" %}'></script>
        <script type='text/javascript' src='{% media  "/media/js/youtube.js" %}'></script>
        <link rel="stylesheet" type="text/css" href="{% media  "/media/js/viewbox.css" %}" />
        {% endif %}
        {% endif %}

        <script type="text/javascript">
        $().ready(function(){
            $("#nav_issues").attr('className',"on");
            var answer_sort_tab = "{{ tab_id }}";

            if (answer_sort_tab) {
                $("#" + answer_sort_tab).attr('className',"on");
            }

            $('#editor').TextAreaResizer();

            //toggle preview of editor
            var display = true;
            var txt = "[{% trans "hide preview" %}]";
            $('#pre-collapse').text(txt);
            $('#pre-collapse').bind('click', function(){
                txt = display ? "[{% trans "show preview" %}]" : "[{% trans "hide preview" %}]";
                display = !display;
                $('#previewer').toggle();
                $('#pre-collapse').text(txt);
            });
        });

        function submitClicked(e, f) {
            if(!(browserTester('chrome') || browserTester('safari'))) {
                $("input.submit")[0].disabled=true;
            }
            window.removeEventListener('beforeunload', beforeUnload, true);
            if (f) {
                f.submit();
            }
        }

        function beforeUnload(e) {

            if($("textarea#editor")[0].value != "") {
                return yourWorkWillBeLost(e);
            }

            var commentBoxes = $("textarea.commentBox");
            for(var index = 0; index < commentBoxes.length; index++) {
                if(commentBoxes[index].value != "") {
                    return yourWorkWillBeLost(e);
                }
            }
        }
        window.addEventListener('beforeunload', beforeUnload, true);
        </script>
        <noscript>
            <style>
                .comment.not_top_scorer {
                    display: block;
                }
                .comment-form-container {
                    display: block;
                }
                .div.comment-tools {
                    display: none;
                }
            </style>
        </noscript>
{% endblock %}
        
{% block content %}
<div class="headNormal">
    <h1><a href="{{ issue.get_absolute_url }}">{{ issue.headline }}</a></h1>
</div>
<div id="main-body" class="">
    <div id="askform">
            <table style="width:100%;" id="issue-table" {% post_classes issue %}>
                <tr>
                    <td style="width:30px;vertical-align:top">
                        <div class="vote-buttons">
                            {% vote_buttons issue request.user %}
                            {% favorite_mark issue request.user %}                            
                        </div>
                    </td>
                    <td>
                        <div id="item-right">
                            <div class="issue-body">
                                {{ issue.html|safe }}
                            </div>
                            <div id="issue-tags" class="tags-container tags">
                                {% for tag in issue.tagname_list %}
                                    <a href="{% url tag_issues tag|urlencode %}" class="post-tag tag-link-{{ tag }}"
                                        title="{% blocktrans with tag as tagname %}see issues tagged '{{ tagname }}'{% endblocktrans %}" rel="tag">{{ tag }}</a>
                                {% endfor %}
                            </div>
                            <div id="issue-controls" class="post-controls">                            
                                {% post_controls issue request.user %}
                                {% wiki_symbol request.user issue %}
                            </div>
                            <div class="post-update-info-container">
                                    {% contributors_info issue %}
                            </div>
                            {% comments issue request.user %}
                        </div>
                        
                    </td>
                </tr>
            </table>
            {% if issue.nis.closed %}
            <div class="issue-status" style="margin-bottom:15px">
            <h3>
                {% blocktrans with issue.nstate.closed.extra as close_reason %}The issue has been closed for the following reason "{{ close_reason }}" by{% endblocktrans %}
                <a href="{{ issue.nstate.closed.by.get_profile_url }}">{{ issue.nstate.closed.by.username }}</a>
                 {% diff_date issue.nstate.closed.at %}
            </h3>
            </div>
            {% endif %}
						<div class='ProCons'>
							<div class='column proColumn'>
								<div class='heading proHeading'><span class="proText">Pro</span></div>
								{% if pros %}
                	{% for reason in pros.paginator.page %}
										<div class='positionSupportCell'>
                      <div class="vote-buttons">
                          {% vote_buttons reason request.user %}
                      </div>
											<div class='reason-body'>
												{{ reason.html|safe }}
											</div>
                      <div class="reason-controls post-controls">
                        {% post_controls reason request.user %}
                        {% wiki_symbol request.user reason %}
                      </div>
										</div>
                	{% endfor %}
								{% endif %}
								<div>
            		{% if not issue.closed %}
        					<a href="{% url new_reason pro_position.id %}">Submit new pro</a>
								{% endif %}
								</div>
							</div>
							<div class='column conColumn'>
								<div class='heading conHeading'><span class="conText">Con</span></div>
								{% if cons %}
                	{% for reason in cons.paginator.page %}
										<div class='positionSupportCell'>
                      <div class="vote-buttons">
                          {% vote_buttons reason request.user %}
                      </div>
											<div class='reason-body'>
												{{ reason.html|safe }}
											</div>
                      <div class="reason-controls post-controls">
                        {% post_controls reason request.user %}
                        {% wiki_symbol request.user reason %}
                      </div>
										</div>
                	{% endfor %}
								{% endif %}
            		{% if not issue.closed %}
        					<a href="{% url new_reason con_position.id %}">Submit new con</a>
								{% endif %}
							</div>
						</div>
    </div>
</div>
{% endblock %}

{% block sidebar %}
<div class="boxC" id="subscription_box">
    {% include "subscription_status.html" %}
</div>

{% markdown_help %}

{% sidebar_upper %}

{% cache 60 issues_tags settings.APP_URL issue.id %}
<div class="boxC">
    <p>
		{% trans "Question tags" %}:
    </p>
    <p class="tags" >
        {% for tag in issue.tags.all %}
        	<a href="{% url tag_issues tag.name|urlencode %}"
            class="tag-link-{{ tag.name }}"
			title="{% trans "see issues tagged"%}'{{tag.name}}'{% trans "using tags" %}"
			rel="tag">{{ tag.name }}</a> <span class="tag-number">&#215;{{ tag.used_count|intcomma }}</span><br/>
        {% endfor %}
    </p>
    <p>
        {% trans "issues submitted" %}: <strong title="{{ issue.added_at }}">{% diff_date issue.added_at %}</strong>
    </p>
    <p> 
     	{% trans "issue was seen" %}: <strong>{{ issue.view_count|intcomma }} {% trans "times" %}</strong>
    </p>
    <p> 
        {% trans "last updated" %}: <strong title="{{ issue.last_activity_at }}">{% diff_date issue.last_activity_at %}</strong>
    </p>
</div>
{% endcache %}
{% sidebar_lower %}
<div class="boxC">
    <h3 class="subtitle">{% trans "Related issues" %}</h3>
    <div class="issues-related">

        {% for issue in similar_issues %}
        <p>
            <a href="{{ issue.get_absolute_url }}">{{ issue.headline }}</a>
        </p>
        {% endfor %}

    </div>
</div>

{% endblock %}

{% block endjs %}
{% endblock %}
<!-- end issue.html -->
